package part01_七大原则.p03_依赖倒转原则.依赖关系传递的三种方式;

/**
 * @ClassName: DependencyPass03
 * @Author: AllenSun
 * @Date: 2019/12/3 0:19
 */
public class DependencyPass03 {
    public static void main(String[] args) {
        GeLi geLi = new GeLi();
        OpenAndClose03 openAndClose03 = new OpenAndClose03();
        openAndClose03.setTv(geLi);
        openAndClose03.open();
    }
}

interface IOpenAndClose03{
    public void open();
    public void setTv(ITV03 tv);
}

interface ITV03{
    public void play();
}

class OpenAndClose03 implements IOpenAndClose03{

    private ITV03 tv;

    @Override
    public void open() {
        this.tv.play();
    }

    @Override
    public void setTv(ITV03 tv) {
        this.tv=tv;
    }
}

class GeLi implements ITV03{

    @Override
    public void play() {
        System.out.println("格力电视机，打开");
    }
}